The JavaScript Cookbook Cookie Routines

Use these routines to set and retrieve persistent data from the user's site. Cookies are small pieces of data that can be stored between visits to your page. Use cookies to: Cookies are stored in your Netscape directory (in the Preferences folder if you are on a Macintosh). Look for a file named .cookie or MagicCookie, etc. This file stores all cookie information and will looks similar to the following:

# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This is a generated file!  Do not edit.

	FALSE	/JavaScript%20Cookbook/DOSFILES/COOKIES	FALSE	859608597	UserTimes	5
	FALSE	/JavaScript%20Cookbook/DOSFILES/COOKIES	FALSE	859608540	UserColor	FF7777
	FALSE	/JavaScript%20Cookbook/DOSFILES/COOKIES	FALSE	859608540	UserName	Erica
These examples progress through an entire series of transactions which use the JavaScript Cookbook Cookie library. The library calls are shown for each example. These are not standard Cookie calls, but ones that have been developed especially for this CD-ROM and are now made available to you. These routines make cookie-baking a pleasure rather than a chore.

These examples use the "Acme" sample data from the official Netscape HTTP Cookies reference sheet. This helps the reader orient between these JavaScript Cookbook routines and the built-in Netscape JavaScript routines. (This link may change without prior notice).

An important note. In early versions of Netscape Navigator, cookies will expire immediately unless their path is set to "/".



Copyright ©1998 by Charles River Media, All Rights Reserved